// pages/first/first.js
const app = getApp()
Page({

    unfold(e){
      wx.redirectTo({   //wx.redirectTo也可以
        url:'/pages/show/show'//在配置文件中页面要在page中
    })
      console.log("jjjjj")
    },
    // 收藏点击事件
    del(e){
      let str='';
      (this.data.coll=="e1.png")?str="e2.png":str="e1.png";
        this.setData({
         coll:str          
       })
       var logs;
       (this.data.coll=="e1.png")?logs="已收藏":logs="已取消收藏";
       console.log(logs);
    },
  stopTouchMove: function() {
    return false;
    },
  getUserInfo: function(e) {
    console.log(e)
    app.globalData.userInfo = e.detail.userInfo
    this.setData({
      userInfo: e.detail.userInfo,
      hasUserInfo: true
    })
  },
  linkfun(event){
    let appArr=[];
    var heights=this.data.height;
    // 获取一级成员的数组个数

   var sell=[this.data.sell.length,this.data.sell1.length];
   var issell=sell[event.currentTarget.dataset.index];
    for(let i=0;i<this.data.navi.length;i++){
     if( event.currentTarget.dataset.index==i){
       appArr.push("color_red");
     }else{
       appArr.push("color_black");
     }
      };
      this.setData({
        navi:appArr,
       currentTab:event.currentTarget.dataset.index,
       swiperheight:heights*issell,
    })
  },
  /**
   * 页面的初始数据
   */
  data: {
    images:[
      {
      img1:"../../imgs/x1.jpg",
    },
    {
      img1:"../../imgs/x2.jpg",
    },
    {
      img1:"../../imgs/x3.jpg",
    }, {
      img1:"../../imgs/x4.jpg",
    }
  ],
  sell:[
    {
      img:"01.png",
      bookname:"高等数学上",
      qq:"qq：2018211483"
    },
    {
      img:"01.png",
      bookname:"高等数学上",
      qq:"qq：2018211483"
    },
    {
      img:"01.png",
      bookname:"高等数学上",
      qq:"qq：2018211483"
    },
    {
      img:"01.png",
      bookname:"高等数学上",
      qq:"qq：2018211483"
    },
  ],
  sell1:[
      {
        img:"02.png",
        bookname:"高等数学上",
        qq:"qq：2018211483"
      },
      {
        img:"02.png",
        bookname:"高等数学上",
        qq:"qq：2018211483"
      },
      {
        img:"02.png",
        bookname:"高等数学上",
        qq:"qq：2018211483"
      },
      {
        img:"02.png",
        bookname:"高等数学上",
        qq:"qq：2018211483"
      },
  ],
    swiperobject1:[
      {
        img:"01.png",
        name:"全部"
      },
      {
        img:"02.png",
        name:"数学"
      },
      {
        img:"03.png",
        name:"外语"
      },
      {
        img:"09.png",
        name:"政治"
      },
      {
        img:"05.png",
        name:"物理"
      },
      {
        img:"06.png",
        name:"计算机"
      },
      {
        img:"07.png",
        name:"机械"
      },
      {
        img:"08.png",
        name:"金融"
      }
    ],
    swiperobject2:[
      {
        img:"09.png",
        name:"文学"
      },
      {
        img:"10.png",
        name:"法学"
      },
      {
        img:"11.png",
        name:"医学"
      },
      {
        img:"01.png",
        name:"其他"
      }

    ],
    swiperheight:0,
    height:125,
    currentTab:1,
    navi:["color_black","color_black","color_black","color_black","color_black","color_black","color_black","color_black","color_black","color_black","color_black","color_black"],
    coll:"e2.png"
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var heights=this.data.height;
    // 获取一级成员的数组个数
    var sell = this.data.sell.length;
    this.setData({
     swiperheight:heights*sell,
     currentTab:0
  })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})